package com.wlc.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class ThirdService {

    @Autowired
    RestTemplate restTemplate;

    public String getDataFromThirdParty(){
        String response = this.callThirdPartyApi("http://localhost:8080/api/v1/order/createOrderNo");
        System.out.println("response = " + response);
        return response;
    }
    public String callThirdPartyApi(String url) {
        // GET 请求示例
        String response = restTemplate.getForObject(url, String.class);
        return response;
    }

    public <T> T postToThirdParty(String url, Object request, Class<T> responseType) {
        // POST 请求示例
        return restTemplate.postForObject(url, request, responseType);
    }
}
